home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 26.zip / BS1 part 26 / Aztec C v5.2a disk 4.adf / 204inc_h.lzh / intuition / classes.h < prev    next >
C/C++ Source or Header  |  1991-03-14  |  3KB  |  86 lines

  1. #ifndef    INTUITION_CLASSES_H
  2. #define INTUITION_CLASSES_H    1
  3. /*
  4. **  $Filename: intuition/classes.h $
  5. **  $Release: 2.04 $
  6. **  $Revision: 36.1 $
  7. **  $Date: 90/11/01 $
  8. **
  9. **  Used only by class implementors
  10. **
  11. **  (C) Copyright 1985,1986,1987,1988,1989,1990 Commodore-Amiga, Inc.
  12. **        All Rights Reserved
  13. */
  14.  
  15. #ifndef UTILITY_HOOKS_H
  16. #include <utility/hooks.h>
  17. #endif
  18.  
  19. #ifndef    INTUITION_CLASSUSR_H
  20. #include <intuition/classusr.h>
  21. #endif
  22.  
  23. /*******************************************/
  24. /*** "White box" access to struct IClass ***/
  25. /*******************************************/
  26.  
  27. /* This structure is READ-ONLY, and allocated only by Intuition */
  28. typedef struct IClass {
  29.     struct Hook        cl_Dispatcher;
  30.     ULONG        cl_Reserved;    /* must be 0  */
  31.     struct IClass    *cl_Super;
  32.     ClassID        cl_ID;
  33.  
  34.     /* where within an object is the instance data for this class? */
  35.     UWORD        cl_InstOffset;
  36.     UWORD        cl_InstSize;
  37.  
  38.     ULONG        cl_UserData;    /* per-class data of your choice */
  39.     ULONG        cl_SubclassCount;
  40.                     /* how many direct subclasses?    */
  41.     ULONG        cl_ObjectCount;
  42.                 /* how many objects created of this class? */
  43.     ULONG        cl_Flags;
  44. #define    CLF_INLIST    0x00000001    /* class is in public class list */
  45. } Class;
  46.  
  47. /* add offset for instance data to an object handle */
  48. #define INST_DATA( cl, o )    ((VOID *) (((UBYTE *)o)+cl->cl_InstOffset))
  49.  
  50. /* sizeof the instance data for a given class */
  51. #define SIZEOF_INSTANCE( cl )    ((cl)->cl_InstOffset + (cl)->cl_InstSize \
  52.             + sizeof (struct _Object ))
  53.  
  54. /**************************************************/
  55. /*** "White box" access to struct _Object    ***/
  56. /**************************************************/
  57.  
  58. /*
  59.  * We have this, the instance data of the root class, PRECEDING
  60.  * the "object".  This is so that Gadget objects are Gadget pointers,
  61.  * and so on.  If this structure grows, it will always have o_Class
  62.  * at the end, so the macro OCLASS(o) will always have the same
  63.  * offset back from the pointer returned from NewObject().
  64.  *
  65.  * This data structure is subject to change.  Do not use the o_Node
  66.  * embedded structure.
  67.  */
  68. struct _Object {
  69.     struct MinNode    o_Node;
  70.     struct IClass    *o_Class;
  71. };
  72.  
  73. /* convenient typecast    */
  74. #define _OBJ( o )    ((struct _Object *)(o))
  75.  
  76. /* get "public" handle on baseclass instance from real beginning of obj data */
  77. #define BASEOBJECT( _obj )    ( (Object *) (_OBJ(_obj)+1) )
  78.  
  79. /* get back to object data struct from public handle */
  80. #define _OBJECT( o )        (_OBJ(o) - 1)
  81.  
  82. /* get class pointer from an object handle    */
  83. #define OCLASS( o )    ( (_OBJECT(o))->o_Class )
  84.  
  85. #endif
  86.